package com.syf.kit.core.dao.tx;

/**
 * syf service内数据库事务存储
 */
public class SyfServiceRdsDbTxStorage {
    private static final ThreadLocal<Boolean> txBeginFlag = new ThreadLocal<>();

    /**
     * syf service开启事务
     * */
    public static void beginDbTx() {
        txBeginFlag.set(Boolean.TRUE);
    }

    /**
     * syf service事务是否开启的标志状态
     * */
    public static Boolean getTxStatus() {
        if (txBeginFlag.get() == null){
            return Boolean.FALSE;
        }

        return txBeginFlag.get();
    }

    /**
     * syf service内关闭事务
     * */
    public static void closeDbTx() {
        txBeginFlag.remove();
    }
}
